package samples.d1
{
	import flash.display.CapsStyle;
	import flash.display.LineScaleMode;
	import flash.filters.GlowFilter;
	import flash.utils.setInterval;
	import samples.BaseSample;
	import shapes.shapes2D.Dot;
	import shapes.shapes2D.Line;
	/**
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class Sample51 extends BaseSample
	{
		
		private var line:Line;
		private var d0:Dot;
		private var d1:Dot;
		
		public function Sample51() 
		{
			
			filters = [new GlowFilter( color, 1, 12, 12, 2, 3 ) ];
			
			d0 = new Dot( 100, sh / 2 );
			d1 = new Dot( sw - 100, sh / 2 );
			line = new Line( d0, d1 );
			line.start = 0;
			line.end = -1;
			
			interval = setInterval( render, 30 );
			
		}
		
		private function render():void
		{
			
			var seed:Number = Math.random() * .01;
			
			line.start += seed;
			line.end = ( line.start - 1 ) +.0025;
			
			if ( line.start >= 1 )
			{
				line.start = 0;
				graphics.clear();
				return;
			}
			
			graphics.lineStyle( 0, color );
			d0.draw( graphics );
			d1.draw( graphics );
			
			graphics.lineStyle( Math.random() < .1 ? 20 : 0, color, 1, false, LineScaleMode.NORMAL, CapsStyle.SQUARE );
			line.draw( graphics );
			
		}
		
	}

}